// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import mainManage from "../../framework/mainManage";
import Tool from "../../framework/Tool";
import gameData from "../gameData";

const {ccclass, property} = cc._decorator;

export enum directionList {
    Horizontal = 0,
    Vertical = 1
}

@ccclass
export default class skinViewMediator extends cc.Component {

    @property({visible : false})
    Direction : directionList = directionList.Horizontal;

    @property({type : cc.Enum(directionList),displayName : "模式"})
    get updateDirection() : directionList{
        return this.Direction;
    }
    set updateDirection(value){
        if (this.Direction === value) {
            return;
        }
        this.Direction = value;
        this._initItemPos();
    }

    @property({visible : false})
    itemOffset : number = 0;
    @property({displayName : "每个item间隔"})
    get positionGet(): number{
        return this.itemOffset;
    }
    set positionGet(value: number){
        if (this.itemOffset === value) {
            return;
        }
        this.itemOffset = value;
        this._initItemPos();
    }

    @property({visible : false})
    speed : number = 0;

    @property({displayName : "移动速度"})
    get speedGet(): number{
        return this.speed;
    }
    set speedGet(value: number){
        if (this.speed === value) {
            return;
        }
        this.speed = value;
        this._initItemPos();
    }

    @property
    item : cc.Node[] = [];

    @property({type : cc.Node,displayName : "滚动item"})
    get itemGet(){
        return this.item;
    }
    set itemGet(value){
        this._initItemPos();
    }

    @property({displayName : "减速频率"})
    rub : number = 1.0;

    @property({displayName : "缩放最小值"})
    scaleMin : number = 0.5;

    @property({displayName : "缩放最大值"})
    scaleMax : number = 1;

    @property({type : cc.Node,displayName : "按钮节点"})
    btnNode : cc.Node = null;

    @property(cc.Label)
    totalNumber : cc.Label = null;

    @property(cc.Label)
    appleNumber : cc.Label = null;

    @property(cc.Node)
    colorListNode : cc.Node = null;

    @property(cc.Node)
    skinBtn : cc.Node = null;

    @property(cc.Label)
    skinPieceLab : cc.Label = null;

    @property(cc.Node)
    maskNode : cc.Node = null;

    @property(cc.Node)
    skinNameNode : cc.Node = null;

    @property(cc.Node)
    christmasSkin : cc.Node = null;

    @property(cc.Node)
    pieceList : cc.Node = null;

    @property(cc.Label)
    pieceLab : cc.Label = null;

    @property(cc.Node)
    duckNode : cc.Node = null;

    appleTotal = 0;

    _startTime = 0;

    _moveSpeed = 0;

    _maxSize = null;

    _screenRect = null;

    itemList = [];

    initSetPos = null;

    _initItemPos() {
        this.node.anchorY = 0.5;
        this.node.anchorX = 0.5;
        this._maxSize = new cc.Size(0, 0);
        for (let i = 0; i < this.item.length; i++) {
            this._maxSize.width += this.item[i].width;
            this._maxSize.height += this.item[i].height;
            this._maxSize.width += this.itemOffset;
            this._maxSize.height += this.itemOffset;
        }
        let startPos;
        if (this.Direction == 0) {
            // startPos = cc.v2(this._maxSize.width * this.node.anchorX, -this._maxSize.height * this.node.anchorY);
            if(this.initSetPos != null){
                startPos = cc.v2(this.item[0].x - this.item[1].x, -this._maxSize.height * this.node.anchorY);
            }else{
                startPos = cc.v2(0, -this._maxSize.height * this.node.anchorY);
            }

        } else {
            startPos = cc.v2(this._maxSize.width * this.node.anchorX, this._maxSize.height * this.node.anchorY / 2);
        }
        this._screenRect = new cc.Rect(startPos.x, startPos.y, this._maxSize.width, this._maxSize.height);
        for (let i = 0; i < this.item.length; i++) {
            let anchor = this.item[i].getAnchorPoint();
            let itemSize = this.item[i].getContentSize();

            if (this.Direction == 0) {
                startPos.addSelf(cc.v2(itemSize.width * anchor.x, itemSize.height * anchor.y));
                this.item[i].x = startPos.x;
                this.item[i].y = 0;
                startPos.addSelf(cc.v2(itemSize.width * anchor.x, itemSize.height * anchor.y));
                startPos.addSelf(cc.v2(this.itemOffset, this.itemOffset));
            } else {
                startPos.subSelf(cc.v2(itemSize.width * anchor.x, itemSize.height * anchor.y));
                this.item[i].x = 0;
                this.item[i].y = startPos.y;
                startPos.subSelf(cc.v2(itemSize.width * anchor.x, itemSize.height * anchor.y));
                startPos.subSelf(cc.v2(this.itemOffset, this.itemOffset));
            }
            this.itemList[i] = this.item[i];
        }
    }

    useData = 0;
    onLoad(){
        this._initItemPos();
        this.updateScale();
        //获取七种皮肤碎片
        this.curSevenSkin = gameData.lastColorfulList[2];
        //拥有皮肤的数据
        let processData = gameData.getRoleProcessSkin();
        //当前使用的皮肤
        this.useData = gameData.getCurUseRoleSkin();

        let index = 0;

        for (let i = 0; i < this.item.length; i++) {

            if(processData[i] == 1){
                index++;
                this.item[i].getChildByName("lock").active = false;
                if(i == 0){
                    this.btnNode.getChildByName("bg3").active = false;
                    this.btnNode.getChildByName("bg1").active = true;
                }
            }else{
                if(i == 0){
                    this.btnNode.getChildByName("bg3").active = true;
                }
            }

            if(this.useData == i){
                this.item[i].getChildByName("use").active = true;
                if(i == 0){
                    this.btnNode.getChildByName("bg2").active = true;
                }
            }

            // if(i < 12){
            //     if(processData[i] == 1){
            //         index++;
            //         this.item[i + 10].getChildByName("lock").active = false;
            //         if(i == 0){
            //             this.btnNode.getChildByName("bg3").active = false;
            //             this.btnNode.getChildByName("bg1").active = true;
            //         }
            //     }else{
            //         if(i == 0){
            //             this.btnNode.getChildByName("bg3").active = true;
            //         }
            //     }

            //     if(this.useData == i){
            //         this.item[i + 10].getChildByName("use").active = true;
            //         if(i == 0){
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }
            //     }

                // if(i == 11 && (processData[11] == 1 || gameData.colorfulPiece[0][6] == 1)){
                //     this.item[20].getChildByName("piece7").active = false;
                // }else{
                //     this.item[20].getChildByName("piece7").active = true;
                // }

            // }else {

            //     this.item[i].active = false;

            //     if(i == 13){
            //         index++;
            //         if(processData[13] == 1) {
            //             this.item[0].getChildByName("lock").active = false;
            //             this.node.getChildByName("skinName").active = true;
            //             this.node.getChildByName("eggBtn").active = false;
            //         }else{
            //             this.node.getChildByName("skinName").active = true;
            //             this.node.getChildByName("nameBtn").active = true;
            //             if(gameData.getRoleProcessSkin()[13] == 0 && gameData.getColorfulPieceNumber(gameData.colorfulPiece[1]) == 5){
            //                 this.node.getChildByName("eggBtn").active = false;
            //                 this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
            //                 this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
            //             }else if(gameData.getRoleProcessSkin()[13] == 0 && gameData.getColorfulPieceNumber(gameData.colorfulPiece[1]) < 5){
            //                 this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
            //                 this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
            //             }
            //         }
            //         for(let j in this.skinNameNode.children){
            //             if(gameData.colorfulPiece[1][j] == 1){
            //                 this.skinNameNode.children[j].getChildByName("que").active = false;
            //                 this.skinNameNode.children[j].getChildByName("show").active = true;
            //             }
            //         }
            //         if (this.useData == 13) {
            //             this.item[0].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     }else if(i == 12){
            //         index++;
            //         if (processData[12] == 1) {
            //             this.item[1].getChildByName("lock").active = false;
            //         }else{
            //             for(let j in this.maskNode.children){
            //                 if(gameData.colorfulPiece[0][j] == 1){
            //                     this.maskNode.children[j].children[0].active = true;
            //                 }
            //             }
            //             let piece = gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]);
            //             this.skinPieceLab.string = "(" + piece + " / " + gameData.colorfulPiece[0].length + ")";
            //         }
            //         let spk = this.item[1].getChildByName("demoMan").getComponent(sp.Skeleton);
            //         spk.setSkin("pfi" + (gameData.lastColorfulPart + 1));
            //         this.colorListNode.children[gameData.lastColorfulPart].children[0].active = true;
            //         this.lastColorIndex = gameData.lastColorfulPart;

            //         if (this.useData == 12) {
            //             this.item[1].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     }else if(i == 14){
            //         index++;
            //         if (processData[14] == 1) {
            //             this.item[2].getChildByName("lock").active = false;
            //         }

            //         if (this.useData == 14) {
            //             this.item[2].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     }else if(i == 15){
            //         index++;
            //         if (processData[15] == 1) {
            //             this.item[3].getChildByName("lock").active = false;
            //         }

            //         if (this.useData == 15) {
            //             this.item[3].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     }else if(i == 16){
            //         index++;
            //         if (processData[16] == 1) {
            //             this.item[4].getChildByName("lock").active = false;
            //         }
            //         if (this.useData == 16) {
            //             this.item[4].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //         this.christmasSkin.children[gameData.lastColorfulList[1]].children[0].active = true;
            //         let spk = this.item[4].getChildByName("demoMan").getComponent(sp.Skeleton);
            //         spk.setSkin("pifu" + (gameData.lastColorfulList[1] + 1));
            //     } else if(i == 17){
            //         index++;
            //         this.btnNode.active = false;
            //         if (processData[17] == 1) {
            //             this.item[5].getChildByName("lock").active = false;
            //         }
            //         if (this.useData == 17) {
            //             this.item[5].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //         let spk = this.item[5].getChildByName("demoMan").getComponent(sp.Skeleton);
            //         spk.setSkin("pf01");
            //     }else if(i == 18){
            //         index++;
            //         if (processData[18] == 1) {
            //             this.item[6].getChildByName("lock").active = false;
            //         }
            //         if (this.useData == 18) {
            //             this.item[6].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //         let spk = this.item[6].getChildByName("demoMan").getComponent(sp.Skeleton);
            //         spk.setSkin("pf01");
            //     }else if(i == 19){
            //         index++;
            //         if (processData[19] == 1) {
            //             this.item[7].getChildByName("lock").active = false;
            //         }
            //         if (this.useData == 19) {
            //             this.item[7].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     } else if(i == 20){
            //         index++;
            //         if (processData[20] == 1) {
            //             this.item[8].getChildByName("lock").active = false;
            //             if(gameData.colorfulPiece[5][0] == 0 && gameData.colorfulPiece[5][1] == 0) {
            //                 this.curSevenSkin = 0;
            //                 this.loadSevenSkin(1,this.item[8].getChildByName("demoMan"));
            //                 this.node.getChildByName("seven").children[0].children[0].active = true;
            //             }if(gameData.colorfulPiece[5][0] == 1 && gameData.colorfulPiece[5][1] == 0){
            //                 this.curSevenSkin = 0;
            //                 this.loadSevenSkin(1,this.item[8].getChildByName("demoMan"));
            //                 this.node.getChildByName("seven").children[0].children[0].active = true;
            //             }else if(gameData.colorfulPiece[5][0] == 0 && gameData.colorfulPiece[5][1] == 1){
            //                 this.curSevenSkin = 1;
            //                 this.loadSevenSkin(2,this.item[8].getChildByName("demoMan"));
            //                 this.node.getChildByName("seven").children[1].children[0].active = true;
            //             }else if(gameData.colorfulPiece[5][0] == 1 && gameData.colorfulPiece[5][1] == 1){
            //                 this.loadSevenSkin(this.curSevenSkin + 1,this.item[8].getChildByName("demoMan"));
            //                 this.node.getChildByName("seven").children[this.curSevenSkin].children[0].active = true;
            //             }
            //         }else{
            //             this.curSevenSkin = 0;
            //             this.loadSevenSkin(gameData.lastColorfulList[2] + 1,this.item[8].getChildByName("demoMan"));
            //             this.node.getChildByName("seven").children[0].children[0].active = true;
            //         }
            //         if (this.useData == 20) {
            //             this.item[8].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     }else if(i == 21){
            //         index++;
            //         if (processData[21] == 1) {
            //             this.item[9].getChildByName("lock").active = false;
            //         }
            //         if (this.useData == 21) {
            //             this.item[9].getChildByName("use").active = true;
            //             this.btnNode.getChildByName("bg2").active = true;
            //         }else{
            //             this.btnNode.getChildByName("bg2").active = false;
            //         }
            //     }
            // }
        }

        this.btnNode.active = true;

        this.totalNumber.string = index + "," + this.item.length ;

        this.appleTotal = gameData.getCurPumpkinNumber();

        this.appleNumber.string =  "-" + this.appleTotal;

        this.node.on('touchstart', function (event) {
            this._moveSpeed = 0;
            this._startTime = new Date().getTime();
        }.bind(this));

        this.node.on('touchmove', function (event) {
            let movePos = event.getDelta();
            this.itemMoveBy(movePos);
        }.bind(this));

        this.node.on('touchend', function (event) {
            this.touchEnd(event)
        }.bind(this));

        this.node.on('touchcancel', function (event) {
            this.touchEnd(event)
        }.bind(this));


        cc.game.on("moveToTargetPosition",()=>{
            let pos1 = this.item[1].x ;
            for (let i = 0; i < this.item.length; i++) {
                this.item[i].x -= pos1;
            }
            this._moveSpeed = -1;
        })
    }

    callback = null;
    setCallBack(pos){
        this.initSetPos = pos;
        this._moveSpeed = 1;
    }

    setCloseBack(callback){
        if(callback){
            this.callback = callback();
        }
    }

    protected onDestroy(): void {
        cc.game.off("moveToTargetPosition");
    }

    touchEnd(event) {

        let curpos = event.getLocation();
        let startpos = event.getStartLocation();

        let dis;
        if (this.Direction == 0) {
            dis = startpos.x - curpos.x;

        } else {
            dis = startpos.y - curpos.y;
        }

        let curTime = new Date().getTime();
        let disTime = curTime - this._startTime;
        this._moveSpeed = dis / disTime;
    }

    itemMoveBy(pos) {
        let startItem = this.itemList[0];
        let endItem = this.itemList[this.itemList.length - 1];
        if(startItem.x + pos.x >= 0){
            pos.x = -startItem.x;
        }else if(endItem.x + pos.x <= 0){
            pos.x = -endItem.x;
        }
        for (let i = 0; i < this.item.length; i++) {
            if (this.Direction == 0) {
                this.item[i].x += pos.x;
            } else {
                this.item[i].y += pos.y;
            }
        }
        this.updatePos();
    }

    updatePos() {
        this.updateScale();
    }

    showPieceView(){
        Tool.loadPrefab("prefabs/getSkin",res=>{
            let view = cc.instantiate(res);
            if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]) == 7){
                view.getComponent("getSkinMediator").setCallBack(true,7);
            }else{
                view.getComponent("getSkinMediator").setCallBack(false,7);
            }
            view.parent = cc.find("Canvas");
        });
    }

    btnClick(event,data){
        if(Math.abs(this._moveSpeed) > 1) {
            mainManage.createToast("Pilih karakter yang Anda inginkan");
            return;
        }
        let arr  = [];
        for(let i in this.item){
            arr.push(this.item[i].scale);
        }
        let index = this.getMaxIndex(arr);

        console.log("点击");

        if(gameData.getRoleProcessSkin()[index] == 1){
            if(gameData.getCurUseRoleSkin() == index) return;
            this.btnNode.getChildByName("bg1").active = false;
            this.btnNode.getChildByName("bg2").active = true;
            this.btnNode.getChildByName("bg3").active = false;
            this.btnNode.getChildByName("bg4").active = false;
            console.log(gameData.getCurUseRoleSkin());
            this.item[gameData.getCurUseRoleSkin()].getChildByName("use").active = false;
            this.item[index].getChildByName("use").active = true;
            gameData.setCurUseRoleSkin(index);
            gameData.saveLastRoleSkin();
            cc.game.emit("resetRoleSkin");
        }else{
            if(index < 10){
                if(this.appleTotal - gameData.getRoleShopData()[index]["cost"] >= 0){
                    gameData.saveRoleSkin(index);
                    gameData.costPumpkinNumber(gameData.getRoleShopData()[index]["cost"]);
                    this.appleTotal -= gameData.getRoleShopData()[index]["cost"];
                    this.appleNumber.string = ": " + this.appleTotal;
                    this.btnNode.getChildByName("bg4").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                    this.btnNode.getChildByName("bg1").active = true;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.item[index].getChildByName("lock").active = false;
    
                    //针对袜子勇士的修改
                    // if(index == 20 && gameData.colorfulPiece[0][6] == 0){
                    //     this.item[index].getChildByName("piece7").active = false;
                    //     gameData.colorfulPiece[0][6] = 1;
                    //     gameData.saveColorfulPiece();
                    //     Tool.loadPrefab("prefabs/getSkin",res=>{
                    //         let view = cc.instantiate(res);
                    //         if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]) == 7){
                    //             view.getComponent("getSkinMediator").setCallBack(true,7);
                    //         }else{
                    //             view.getComponent("getSkinMediator").setCallBack(false,7);
                    //         }
                    //         view.parent = cc.find("Canvas");
                    //     });
                    //     this.item[index].getChildByName("lock").active = false;
                    // }
                    // gameData.saveRoleSkin(index - 8);
                    mainManage.createToast("Pembelian berhasil");
                }else{
                    mainManage.createToast("Jumlah apel tidak mencukupi");
                }
            }else{
                mainManage.createToast("Membuka kunci");
            }  
        }


        //未简化版本的按钮设置
        // if(index == 0){
        //     if(gameData.getRoleProcessSkin()[13] == 1){
        //         if(gameData.getCurUseRoleSkin() == 13) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 17){
        //             this.item[5].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 16){
        //             this.item[4].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 15){
        //             this.item[3].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 12){
        //             this.item[1].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 14){
        //             this.item[2].getChildByName("use").active = false;
        //         }else{
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[0].getChildByName("use").active = true;
        //         gameData.setCurUseRoleSkin(13);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 1){
        //     if(gameData.getRoleProcessSkin()[12] == 1){
        //         if(gameData.getCurUseRoleSkin() == 12) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 17){
        //             this.item[5].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 16){
        //             this.item[4].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 15){
        //             this.item[3].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 13){
        //             this.item[0].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 14){
        //             this.item[2].getChildByName("use").active = false;
        //         }else{
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[1].getChildByName("use").active = true;
        //         if(!this.item[1].getChildByName("use").active){
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }else{
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(12);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 2){
        //     if(gameData.getRoleProcessSkin()[14] == 1){
        //         if(gameData.getCurUseRoleSkin() == 14) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 17){
        //             this.item[5].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 16){
        //             this.item[4].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 15){
        //             this.item[3].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 13){
        //             this.item[0].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 12){
        //             this.item[1].getChildByName("use").active = false;
        //         }else{
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[2].getChildByName("use").active = true;
        //         if(!this.item[2].getChildByName("use").active){
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }else{
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(14);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 3){
        //     if(gameData.getRoleProcessSkin()[15] == 1){
        //         if(gameData.getCurUseRoleSkin() == 15) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 17){
        //             this.item[5].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 16){
        //             this.item[4].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 14){
        //             this.item[2].getChildByName("use").active = false;
        //         } else if(gameData.getCurUseRoleSkin() == 13){
        //             this.item[0].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 12){
        //             this.item[1].getChildByName("use").active = false;
        //         }else{
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[3].getChildByName("use").active = true;
        //         if(!this.item[3].getChildByName("use").active){
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }else{
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(15);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 4){
        //     if(gameData.getRoleProcessSkin()[16] == 1) {
        //         if (gameData.getCurUseRoleSkin() == 16) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 17){
        //             this.item[5].getChildByName("use").active = false;
        //         }else if (gameData.getCurUseRoleSkin() == 15) {
        //             this.item[3].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 13) {
        //             this.item[0].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 14) {
        //             this.item[2].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 12) {
        //             this.item[1].getChildByName("use").active = false;
        //         } else {
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[4].getChildByName("use").active = true;
        //         if (!this.item[4].getChildByName("use").active) {
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         } else {
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(16);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 5){
        //     if(gameData.getRoleProcessSkin()[17] == 1) {
        //         if (gameData.getCurUseRoleSkin() == 17) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 16){
        //             this.item[4].getChildByName("use").active = false;
        //         }else if (gameData.getCurUseRoleSkin() == 15) {
        //             this.item[3].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 13) {
        //             this.item[0].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 14) {
        //             this.item[2].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 12) {
        //             this.item[1].getChildByName("use").active = false;
        //         } else {
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[5].getChildByName("use").active = true;
        //         if (!this.item[5].getChildByName("use").active) {
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         } else {
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(17);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 6){
        //     if(gameData.getRoleProcessSkin()[18] == 1) {
        //         if (gameData.getCurUseRoleSkin() == 18) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if (gameData.getCurUseRoleSkin() == 17) {
        //             this.item[5].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 16) {
        //             this.item[4].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 15) {
        //             this.item[3].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 13) {
        //             this.item[0].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 14) {
        //             this.item[2].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 12) {
        //             this.item[1].getChildByName("use").active = false;
        //         } else {
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[6].getChildByName("use").active = true;
        //         if (!this.item[6].getChildByName("use").active) {
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         } else {
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(18);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 7){
        //     if(gameData.getRoleProcessSkin()[19] == 1) {
        //         if (gameData.getCurUseRoleSkin() == 19) return;
        //         if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if (gameData.getCurUseRoleSkin() == 17) {
        //             this.item[5].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 16) {
        //             this.item[4].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 15) {
        //             this.item[3].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 13) {
        //             this.item[0].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 14) {
        //             this.item[2].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 12) {
        //             this.item[1].getChildByName("use").active = false;
        //         } else {
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[7].getChildByName("use").active = true;
        //         if (!this.item[7].getChildByName("use").active) {
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         } else {
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(19);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else if(index == 8) {
        //     if (gameData.getRoleProcessSkin()[20] == 1) {
        //         if (gameData.getCurUseRoleSkin() == 20) {
        //             if(gameData.seeVideoLockSkin[0] == 1 && this.curSevenSkin == 0){
        //                 this.item[8].getChildByName("use").active = true;
        //                 if (!this.item[8].getChildByName("use").active) {
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 } else {
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //                 gameData.lastColorfulList[2] = 0;
        //                 cc.game.emit("resetRoleSkin");
        //             }else if(gameData.seeVideoLockSkin[1] == 1 && this.curSevenSkin == 1){
        //                 this.item[8].getChildByName("use").active = true;
        //                 if (!this.item[8].getChildByName("use").active) {
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 } else {
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //                 gameData.lastColorfulList[2] = 1;
        //                 cc.game.emit("resetRoleSkin");
        //             }else {
        //                 return;
        //             }
        //         }else{
        //             if(gameData.getCurUseRoleSkin() == 21){
        //                 this.item[9].getChildByName("use").active = false;
        //             }else if (gameData.getCurUseRoleSkin() == 19) {
        //                 this.item[7].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 18) {
        //                 this.item[6].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 17) {
        //                 this.item[5].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 16) {
        //                 this.item[4].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 15) {
        //                 this.item[3].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 13) {
        //                 this.item[0].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 14) {
        //                 this.item[2].getChildByName("use").active = false;
        //             } else if (gameData.getCurUseRoleSkin() == 12) {
        //                 this.item[1].getChildByName("use").active = false;
        //             } else {
        //                 this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //             }
        //             this.item[8].getChildByName("use").active = true;
        //             if (!this.item[8].getChildByName("use").active) {
        //                 this.btnNode.getChildByName("bg1").active = true;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = false;
        //             } else {
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = true;
        //                 this.btnNode.getChildByName("bg3").active = false;
        //             }
        //             gameData.lastColorfulList[2] = this.curSevenSkin;
        //             gameData.setCurUseRoleSkin(20);
        //             gameData.saveLastRoleSkin();
        //             cc.game.emit("resetRoleSkin");
        //         }
        //     }
        // }else if(index == 9){
        //     if(gameData.getRoleProcessSkin()[21] == 1) {
        //         if(gameData.getCurUseRoleSkin() == 21) return;
        //         if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if (gameData.getCurUseRoleSkin() == 19) {
        //             this.item[7].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 18) {
        //             this.item[6].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 17) {
        //             this.item[5].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 16) {
        //             this.item[4].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 15) {
        //             this.item[3].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 13) {
        //             this.item[0].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 14) {
        //             this.item[2].getChildByName("use").active = false;
        //         } else if (gameData.getCurUseRoleSkin() == 12) {
        //             this.item[1].getChildByName("use").active = false;
        //         } else {
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[9].getChildByName("use").active = true;
        //         if (!this.item[9].getChildByName("use").active) {
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         } else {
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = true;
        //             this.btnNode.getChildByName("bg3").active = false;
        //         }
        //         gameData.setCurUseRoleSkin(21);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }
        // }else {
        //     if(gameData.getRoleProcessSkin()[index - 10] == 1){
        //         if(gameData.getCurUseRoleSkin() == index - 10) return;
        //         this.btnNode.getChildByName("bg1").active = false;
        //         this.btnNode.getChildByName("bg2").active = true;
        //         this.btnNode.getChildByName("bg3").active = false;
        //         if(gameData.getCurUseRoleSkin() == 12){
        //             this.item[1].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 13){
        //             this.item[0].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin()== 14){
        //             this.item[2].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 15){
        //             this.item[3].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 16){
        //             this.item[4].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 17){
        //             this.item[5].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 18){
        //             this.item[6].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 19){
        //             this.item[7].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 20){
        //             this.item[8].getChildByName("use").active = false;
        //         }else if(gameData.getCurUseRoleSkin() == 21){
        //             this.item[9].getChildByName("use").active = false;
        //         }else{
        //             this.item[gameData.getCurUseRoleSkin() + 10].getChildByName("use").active = false;
        //         }
        //         this.item[index].getChildByName("use").active = true;
        //         gameData.setCurUseRoleSkin(index - 10);
        //         gameData.saveLastRoleSkin();
        //         cc.game.emit("resetRoleSkin");
        //     }else{
        //         if(this.appleTotal - gameData.getRoleShopData()[index - 10]["cost"] >= 0){
        //             gameData.saveRoleSkin(index - 10);
        //             gameData.costPumpkinNumber(gameData.getRoleShopData()[index - 10]["cost"]);
        //             this.appleNumber.string = ": " + (this.appleTotal - gameData.getRoleShopData()[index - 10]["cost"]);
        //             this.btnNode.getChildByName("bg3").active = false;
        //             this.btnNode.getChildByName("bg1").active = true;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.item[index].getChildByName("lock").active = false;
        //             if(index == 20 && gameData.colorfulPiece[0][6] == 0){
        //                 this.item[index].getChildByName("piece7").active = false;
        //                 gameData.colorfulPiece[0][6] = 1;
        //                 gameData.saveColorfulPiece();
        //                 Tool.loadPrefab("prefabs/getSkin",res=>{
        //                     let view = cc.instantiate(res);
        //                     if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]) == 7){
        //                         view.getComponent("getSkinMediator").setCallBack(true,7);
        //                     }else{
        //                         view.getComponent("getSkinMediator").setCallBack(false,7);
        //                     }
        //                     view.parent = cc.find("Canvas");
        //                 });
        //                 this.item[index].getChildByName("lock").active = false;
        //             }
        //             // gameData.saveRoleSkin(index - 8);
        //             mainManage.createToast("购买成功");
        //         }else{
        //             mainManage.createToast("苹果不够!");
        //         }
        //     }
        // }
    }

    lastColorIndex = 0;
    colorBtnClick(event,data){
        let arr  = [];
        for(let i in this.item){
            arr.push(this.item[i].scale);
        }
        let index = this.getMaxIndex(arr);
        this.colorListNode.children[data -1].children[0].active = true;
        this.colorListNode.children[this.lastColorIndex].children[0].active = false;
        this.lastColorIndex = data - 1;
        gameData.lastColorfulPart = data -1;
        gameData.saveLastColorfulPart();
        let spk = this.item[index].getChildByName("demoMan").getComponent(sp.Skeleton);
        spk.setSkin("pfi" + data);
        if(gameData.getRoleProcessSkin()[12] == 1){
            cc.game.emit("resetRoleSkin");
        }
    }


    //梅花
    christmasBtnClick(event,data){
        let arr  = [];
        for(let i in this.item){
            arr.push(this.item[i].scale);
        }
        let index = this.getMaxIndex(arr);
        this.christmasSkin.children[data -1].children[0].active = true;
        this.christmasSkin.children[gameData.lastColorfulList[1]].children[0].active = false;
        gameData.lastColorfulList[1] = data - 1;
        gameData.saveLastColorfulList();
        let spk = this.item[index].getChildByName("demoMan").getComponent(sp.Skeleton);
        spk.setSkin("pifu" + data);
        if(gameData.getRoleProcessSkin()[16] == 1){
            cc.game.emit("resetRoleSkin");
        }
    }

    //阿七
    curSevenSkin = 0;
    sevenRoleBtnClick(event,data){
        let arr  = [];
        for(let i in this.item){
            arr.push(this.item[i].scale);
        }
        let index = this.getMaxIndex(arr);
        this.node.getChildByName("seven").children[this.curSevenSkin].children[0].active = false;
        this.curSevenSkin = parseInt(data) - 1;
        this.node.getChildByName("seven").children[parseInt(data) - 1].children[0].active = true;
        if(this.curSevenSkin == 0){
            if(gameData.colorfulPiece[5][0] == 0){
                this.item[index].getChildByName("use").active = false;
                this.node.getChildByName("nameBtn").active = true;
                this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
                this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
            }else {
                if(gameData.seeVideoLockSkin[0] == 0){
                    this.item[index].getChildByName("use").active = false;
                    this.node.getChildByName("nameBtn").active = true;
                    this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
                    this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
                }else{
                    gameData.lastColorfulList[2] = 0;
                    gameData.saveLastColorfulList();
                    cc.game.emit("resetRoleSkin");
                    let data = gameData.curUseRoleSkin - 12;
                    if(data == index){
                        this.item[8].getChildByName("use").active = true;
                    }
                    this.node.getChildByName("nameBtn").active = false;
                }
            }
        }else if(this.curSevenSkin == 1){
            if(gameData.colorfulPiece[5][1] == 0){
                this.item[index].getChildByName("use").active = false;
                this.node.getChildByName("nameBtn").active = true;
                this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
                this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
            }else {
                if(gameData.seeVideoLockSkin[1] == 0){
                    this.item[index].getChildByName("use").active = false;
                    this.node.getChildByName("nameBtn").active = true;
                    this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
                    this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
                }else{
                    gameData.lastColorfulList[2] = 1;
                    gameData.saveLastColorfulList();
                    let data = gameData.curUseRoleSkin - 12;
                    cc.game.emit("resetRoleSkin");
                    if(data == index){
                        this.item[8].getChildByName("use").active = true;
                    }
                    this.node.getChildByName("nameBtn").active = false;
                }
            }
        }
        this.loadSevenSkin(parseInt(data),this.item[index].getChildByName("demoMan"));
    }


    loadSevenSkin(data,node){
        if(data == 1){
            cc.loader.loadRes("anim/zhujue22_1",sp.SkeletonData,(error, resource) => {
                if(error){
                    console.log(error);
                    return;
                }
                let spk = node.getComponent(sp.Skeleton);
                spk.skeletonData = resource;
                spk.setAnimation(0,"animation",true);
            })
        }else{
            cc.loader.loadRes("anim/zhujue22_2",sp.SkeletonData,(error, resource) => {
                if(error){
                    console.log(error);
                    return;
                }
                let spk = node.getComponent(sp.Skeleton);
                spk.skeletonData = resource;
                spk.setAnimation(0,"animation",true);
            })
        }
    }

    getMaxIndex(arr) {
        let max = arr[0];
        //声明了个变量 保存下标值
        let index = 0;
        for (let i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
                index = i;
            }
        }
        return index;
    }

    clickEvent = false;
    eggBtnClick(event,data){
        mainManage.createToast("请寻找藏在游戏中的彩蛋哦")
    }

    nameSkinBtn(event,data){
        let arr  = [];
        for(let i in this.item){
            arr.push(this.item[i].scale);
        }
        let index = this.getMaxIndex(arr);
        if(index == 0){
            if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[1]) == 5){
                if(gameData.getRoleProcessSkin()[13] == 0){
                    gameData.saveRoleSkin(13);
                    this.item[0].getChildByName("lock").active = false;
                    this.node.getChildByName("nameBtn").active = false;
                }
            }else{
                mainManage.createToast("请寻找藏在游戏中的狗头大师信物！");
            }
        }else if(index == 1){

            if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]) == 7){
                this.node.getChildByName("nameBtn").active = false;
                this.item[1].getChildByName("lock").active = false;
                this.btnNode.active = true;
                if(!this.item[1].getChildByName("use").active){
                    this.btnNode.getChildByName("bg1").active = true;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                }else{
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = true;
                    this.btnNode.getChildByName("bg3").active = false;
                }
                gameData.saveRoleSkin(12);
                cc.game.emit("resetRoleSkin");
            }else{
                mainManage.createToast("找到游戏中的七块碎片可解锁皮肤");
            }

        }else if(index == 5){

            if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[2]) == 7){
                this.node.getChildByName("nameBtn").active = false;
                this.item[5].getChildByName("lock").active = false;
                this.btnNode.active = true;
                if(!this.item[5].getChildByName("use").active){
                    this.btnNode.getChildByName("bg1").active = true;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                }else{
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = true;
                    this.btnNode.getChildByName("bg3").active = false;
                }
                gameData.saveRoleSkin(17);
                cc.game.emit("resetRoleSkin");
            }else{
                mainManage.createToast("找到游戏中的七颗龙珠即可解锁皮肤");
            }

        }else if(index == 6){

            if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[3]) == 2){
                this.btnNode.active = true;
                this.node.getChildByName("nameBtn").active = false;
                this.item[6].getChildByName("lock").active = false;
                if(!this.item[6].getChildByName("use").active){
                    this.btnNode.getChildByName("bg1").active = true;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                }else{
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = true;
                    this.btnNode.getChildByName("bg3").active = false;
                }
                gameData.saveRoleSkin(18);
                cc.game.emit("resetRoleSkin");
            }else{
                mainManage.createToast("找到游戏中的两个小丑碎片可解锁皮肤");
            }

        }else if(index == 7) {
            if (gameData.getColorfulPieceNumber(gameData.colorfulPiece[4]) == 3) {
                this.btnNode.active = true;
                this.node.getChildByName("nameBtn").active = false;
                this.item[7].getChildByName("lock").active = false;
                if (!this.item[7].getChildByName("use").active) {
                    this.btnNode.getChildByName("bg1").active = true;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                } else {
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = true;
                    this.btnNode.getChildByName("bg3").active = false;
                }
                gameData.saveRoleSkin(19);
                cc.game.emit("resetRoleSkin");
            }else{
                Tool.loadPrefab("mainPrefab/enterDuckLayer", (res) => {
                    let view = cc.instantiate(res);
                    view.parent = cc.find("Canvas");
                })
            }
        }else if(index == 8) {

            if (this.curSevenSkin == 0) {
                if (gameData.colorfulPiece[5][0] == 0) {
                    mainManage.createToast("彩蛋解锁阿七的皮肤");
                } else {
                    if(gameData.seeVideoLockSkin[0] == 0){
                        gameData.seeVideoLockSkin[0] = 1;
                        gameData.saveOtherGameData();
                        this.btnNode.active = true;
                        this.node.getChildByName("nameBtn").active = false;
                        this.item[8].getChildByName("lock").active = false;
                        if (!this.item[8].getChildByName("use").active) {
                            this.btnNode.getChildByName("bg1").active = true;
                            this.btnNode.getChildByName("bg2").active = false;
                            this.btnNode.getChildByName("bg3").active = false;
                        } else {
                            this.btnNode.getChildByName("bg1").active = false;
                            this.btnNode.getChildByName("bg2").active = true;
                            this.btnNode.getChildByName("bg3").active = false;
                        }
                        mainManage.createToast("恭喜解锁阿七的皮肤");
                        gameData.saveRoleSkin(20);
                        cc.game.emit("resetRoleSkin");
                    }
                }

            } else {
                if (gameData.colorfulPiece[5][1] == 0) {
                    mainManage.createToast("彩蛋解锁阿七的皮肤");
                } else {
                    if(gameData.seeVideoLockSkin[1] == 0){
                        gameData.seeVideoLockSkin[1] = 1;
                        gameData.saveOtherGameData();
                        this.btnNode.active = true;
                        this.node.getChildByName("nameBtn").active = false;
                        this.item[8].getChildByName("lock").active = false;
                        if (!this.item[8].getChildByName("use").active) {
                            this.btnNode.getChildByName("bg1").active = true;
                            this.btnNode.getChildByName("bg2").active = false;
                            this.btnNode.getChildByName("bg3").active = false;
                        } else {
                            this.btnNode.getChildByName("bg1").active = false;
                            this.btnNode.getChildByName("bg2").active = true;
                            this.btnNode.getChildByName("bg3").active = false;
                        }
                        mainManage.createToast("恭喜解锁阿七的皮肤");
                        gameData.saveRoleSkin(20);
                        cc.game.emit("resetRoleSkin");
                    }
                }
            }
        }else if(index == 9) {
            gameData.judgeTimeCome(8,()=>{

                if (gameData.getColorfulPieceNumber(gameData.colorfulPiece[6]) == 1) {
                    this.btnNode.active = true;
                    this.node.getChildByName("nameBtn").active = false;
                    this.item[9].getChildByName("lock").active = false;
                    if (!this.item[9].getChildByName("use").active) {
                        this.btnNode.getChildByName("bg1").active = true;
                        this.btnNode.getChildByName("bg2").active = false;
                        this.btnNode.getChildByName("bg3").active = false;
                    } else {
                        this.btnNode.getChildByName("bg1").active = false;
                        this.btnNode.getChildByName("bg2").active = true;
                        this.btnNode.getChildByName("bg3").active = false;
                    }
                    gameData.saveRoleSkin(21);
                    cc.game.emit("resetRoleSkin");
                } else {
                    mainManage.createToast("获取牛气冲天信物才可以解锁哦")
                }

            },()=>{
                mainManage.createToast("2月8日开启获取。")
            })
        }
    }

    updateScale() {
        if (this.scaleMax < this.scaleMin || this.scaleMax == 0) {
            return;
        }
        for (let i = 0; i < this.item.length; i++) {
            let pre;
            if (this.Direction == 0) {
                let x = this.item[i].x + this._maxSize.width / 2;
                if (this.item[i].x < 0) {
                    pre = x / this._maxSize.width;
                }
                else {
                    pre = 1 - x / this._maxSize.width;
                }
            } else {
                let y = this.item[i].y + this._maxSize.height / 2;
                if (this.item[i].y < 0) {
                    pre = y / this._maxSize.height;
                }
                else {
                    pre = 1 - y / this._maxSize.height;
                }
            }
            pre *= 2;
            let scaleTo = this.scaleMax - this.scaleMin;
            scaleTo *= pre;
            scaleTo += this.scaleMin;
            scaleTo = Math.abs(scaleTo);
            this.item[i].scaleX = scaleTo;
            this.item[i].scaleY = scaleTo;
        }
    }

    closeWindow(){
        this.node.destroy();
        if(this.callback != null){
            this.callback();
        }
    }

    isCheck = false;
    update(dt) {
        if (this._moveSpeed == 0) {
            if(!this.isCheck){
                this.isCheck = true;
                let arr  = [];
                for(let i in this.item){
                    arr.push(this.item[i].scale);
                }
                let index = this.getMaxIndex(arr);
                let pos = this.item[index].convertToWorldSpaceAR(cc.v2(0,0));
                let pos2 =  this.node.convertToNodeSpaceAR(pos);
                for(let i in this.item){
                    cc.tween(this.item[i]).by(dt,{
                        position : cc.v2(-pos2.x,0)
                    }).start();
                }
            }
            return;
        }
        this.isCheck = false;

        if(this._moveSpeed){
            let arr  = [];
            for(let i in this.item){
                arr.push(this.item[i].scale);
            }
            let index = this.getMaxIndex(arr);
            this.node.getChildByName("getTime").active = false;

            //简化版本
            this.pieceList.active = false;
            this.duckNode.active = false;
            this.colorListNode.active = false;
            this.christmasSkin.active = false;
            this.btnNode.active = true;
            this.skinBtn.active = false;
            this.node.getChildByName("skinName").active = false;
            this.node.getChildByName("seven").active = false;
            this.node.getChildByName("nameBtn").active = false;
            this.node.getChildByName("cow").active = false;
            this.node.getChildByName("eggBtn").active = false;
            if(gameData.getRoleProcessSkin()[index] == 1){
                if(!this.item[index].getChildByName("use").active){
                    this.btnNode.getChildByName("bg1").active = true;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                    this.btnNode.getChildByName("bg4").active = false;
                }else{
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = true;
                    this.btnNode.getChildByName("bg3").active = false;
                    this.btnNode.getChildByName("bg4").active = false;
                }
            }else{
                if(index < 10){
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = true;
                    this.btnNode.getChildByName("bg4").active = false;
                    let price = this.btnNode.getChildByName("bg3").getChildByName("cost");
                    price.getComponent(cc.Label).string = gameData.getRoleShopData()[index]["cost"] + "";
                }else{
                    this.btnNode.getChildByName("bg1").active = false;
                    this.btnNode.getChildByName("bg2").active = false;
                    this.btnNode.getChildByName("bg3").active = false;
                    this.btnNode.getChildByName("bg4").active = true;
                }
            }


        //     //未简化之前的版本
        //     if(index > 9){
        //         this.pieceList.active = false;
        //         this.duckNode.active = false;
        //         this.colorListNode.active = false;
        //         this.christmasSkin.active = false;
        //         this.btnNode.active = true;
        //         this.skinBtn.active = false;
        //         this.node.getChildByName("skinName").active = false;
        //         this.node.getChildByName("seven").active = false;
        //         this.node.getChildByName("nameBtn").active = false;
        //         this.node.getChildByName("cow").active = false;
        //         if(gameData.getRoleProcessSkin()[index - 10] == 1){
        //             this.node.getChildByName("eggBtn").active = false;
        //             if(!this.item[index].getChildByName("use").active){
        //                 this.btnNode.getChildByName("bg1").active = true;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = false;
        //             }else{
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = true;
        //                 this.btnNode.getChildByName("bg3").active = false;
        //             }
        //             if(index == 20 && gameData.getRoleProcessSkin()[10] != 1 && gameData.colorfulPiece[0][6] != 1){
        //                 this.item[20].getChildByName("piece7").active = true;
        //             }
        //         }else{
        //             if(index == 19 || index == 21){
        //                 this.node.getChildByName("eggBtn").active = true;
        //             }else{
        //                 if(index == 20 && gameData.getRoleProcessSkin()[10] != 1 && gameData.colorfulPiece[0][6] != 1){
        //                     this.item[20].getChildByName("piece7").active = true;
        //                 }
        //                 this.node.getChildByName("eggBtn").active = false;
        //             }
        //             this.btnNode.getChildByName("bg1").active = false;
        //             this.btnNode.getChildByName("bg2").active = false;
        //             this.btnNode.getChildByName("bg3").active = true;
        //         }
        //     }else{
        //         this.btnNode.active = true;
        //         if(index != 5){
        //             this.pieceList.active = false;
        //         }else{
        //             this.pieceList.active = true;
        //         }

        //         if(index != 7){
        //             this.duckNode.active = false;
        //         }else{
        //             this.duckNode.active = true;
        //         }

        //         if(index != 8){
        //             this.node.getChildByName("seven").active = false;
        //         }else{
        //             this.node.getChildByName("seven").active = true;
        //         }

        //         if(index != 9){
        //             this.node.getChildByName("cow").active = false;
        //         }else{
        //             this.node.getChildByName("cow").active = true;
        //         }

        //         if(index == 1){
        //             this.colorListNode.active = true;
        //             this.christmasSkin.active = false;
        //             this.node.getChildByName("skinName").active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[12] == 1){
        //                 this.node.getChildByName("nameBtn").active = false;
        //                 if(!this.item[1].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]) == 7){
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                     this.skinBtn.active = false;
        //                 } else{
        //                     this.node.getChildByName("nameBtn").active = false;
        //                     this.skinBtn.active = true;
        //                     this.btnNode.active = false;
        //                     for(let j in this.maskNode.children){
        //                         if(gameData.colorfulPiece[0][j] == 1){
        //                             this.maskNode.children[j].children[0].active = true;
        //                         }
        //                     }
        //                     let piece = gameData.getColorfulPieceNumber(gameData.colorfulPiece[0]);
        //                     this.skinPieceLab.string = "(" + piece + " / " + gameData.colorfulPiece[0].length + ")";
        //                 }
        //             }
        //         }else if(index == 0) {
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             this.node.getChildByName("skinName").active = true;
        //             if(gameData.getRoleProcessSkin()[13] == 1){
        //                 this.node.getChildByName("nameBtn").active = false;
        //             }else{
        //                 if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[1]) == 5){
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                 }else{
        //                     this.node.getChildByName("nameBtn").active = true;
        //                 }
        //             }
        //             if(!this.item[0].getChildByName("use").active){
        //                 this.btnNode.getChildByName("bg1").active = true;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = false;
        //             }else{
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = true;
        //                 this.btnNode.getChildByName("bg3").active = false;
        //             }
        //             for(let j in this.skinNameNode){
        //                 if(gameData.colorfulPiece[1][j] == 1){
        //                     this.skinNameNode.children[j].getChildByName("show").active = true;
        //                     this.skinNameNode.children[j].getChildByName("que").active = false;
        //                 }
        //             }
        //         }else if(index == 2){
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("skinName").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[14] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[2].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 this.node.getChildByName("eggBtn").active = true;
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //         }else if(index == 3){
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("skinName").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[15] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[3].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 this.node.getChildByName("eggBtn").active = true;
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //         }else if(index == 4){
        //             this.christmasSkin.active = true;
        //             this.colorListNode.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("skinName").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[16] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[4].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 this.node.getChildByName("eggBtn").active = true;
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //             this.skinNameNode.children[gameData.lastColorfulList[1]].getChildByName("show").active = true;
        //         }else if(index == 5){
        //             // this.item[5].active = false;
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             // this.btnNode.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             this.node.getChildByName("skinName").active = false;
        //             if(gameData.getRoleProcessSkin()[17] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[5].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[2]) == 7 && gameData.getRoleProcessSkin()[17] == 0){
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                 }else{
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                 }
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //             let children = this.pieceList.getChildByName("piece").children;
        //             for(let j in children){
        //                 if(gameData.colorfulPiece[2][j] == 1){
        //                     children[j].children[0].active = true;
        //                 }
        //             }
        //             let piece = gameData.getColorfulPieceNumber(gameData.colorfulPiece[2]);
        //             this.pieceLab.string = "寻找七颗龙珠即可解锁空空(" + piece + " / " + gameData.colorfulPiece[2].length + ")";
        //         }else if(index == 6){
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[18] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[6].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[3]) == 2 && gameData.getRoleProcessSkin()[18] == 0){
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                 }else{
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                 }
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //         }else if(index == 7){
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[19] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[7].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[4]) == 3 && gameData.getRoleProcessSkin()[19] == 0){
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                 }else{
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                 }
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //             let children = this.duckNode.getChildByName("piece").children;
        //             for(let j in children){
        //                 if(gameData.colorfulPiece[4][j] == 1){
        //                     children[j].children[0].active = true;
        //                 }
        //             }
        //             let piece = gameData.getColorfulPieceNumber(gameData.colorfulPiece[4]);
        //             this.duckNode.getChildByName("lab").getComponent(cc.Label).string = "收集3个鸭仔碎片即可解锁鸭仔(" + piece + " / " + gameData.colorfulPiece[4].length + ")";
        //         }else if(index == 8){
        //             this.node.getChildByName("seven").active = true;
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[20] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(this.curSevenSkin == 0){
        //                     if(gameData.colorfulPiece[5][0] == 0){
        //                         this.node.getChildByName("nameBtn").active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                     }else {
        //                         if(gameData.seeVideoLockSkin[0] == 0){
        //                             this.node.getChildByName("nameBtn").active = true;
        //                             this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                             this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                         }
        //                     }
        //                 }else if(this.curSevenSkin == 1){
        //                     if(gameData.colorfulPiece[5][1] == 0){
        //                         this.node.getChildByName("nameBtn").active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                     }else{
        //                         if(gameData.seeVideoLockSkin[1] == 0){
        //                             this.node.getChildByName("nameBtn").active = true;
        //                             this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                             this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                         }
        //                     }
        //                 }

        //                 if(!this.item[8].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 if(gameData.colorfulPiece[5][this.curSevenSkin] == 0){
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                 }else{
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                 }
        //                 this.btnNode.getChildByName("bg1").active = false;
        //                 this.btnNode.getChildByName("bg2").active = false;
        //                 this.btnNode.getChildByName("bg3").active = true;
        //             }
        //         }else if(index == 9){
        //             this.colorListNode.active = false;
        //             this.christmasSkin.active = false;
        //             this.btnNode.active = true;
        //             this.skinBtn.active = false;
        //             this.node.getChildByName("eggBtn").active = false;
        //             this.node.getChildByName("nameBtn").active = false;
        //             if(gameData.getRoleProcessSkin()[21] == 1){
        //                 this.node.getChildByName("eggBtn").active = false;
        //                 if(!this.item[9].getChildByName("use").active){
        //                     this.btnNode.getChildByName("bg1").active = true;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }else{
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = true;
        //                     this.btnNode.getChildByName("bg3").active = false;
        //                 }
        //             }else{
        //                 gameData.judgeTimeCome(8,()=>{
        //                     this.node.getChildByName("getTime").active = false;
        //                     if(gameData.getColorfulPieceNumber(gameData.colorfulPiece[6]) == 1 && gameData.getRoleProcessSkin()[21] == 0){
        //                         this.node.getChildByName("nameBtn").active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = false;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = true;
        //                     }else{
        //                         this.node.getChildByName("nameBtn").active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                         this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                     }
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = true;
        //                 },()=>{
        //                     this.node.getChildByName("getTime").active = true;
        //                     this.node.getChildByName("nameBtn").active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[0].active = true;
        //                     this.node.getChildByName("nameBtn").getChildByName("Background").children[1].active = false;
        //                     this.btnNode.getChildByName("bg1").active = false;
        //                     this.btnNode.getChildByName("bg2").active = false;
        //                     this.btnNode.getChildByName("bg3").active = true;
        //                 });
        //             }

        //             let children = this.node.getChildByName("cow").children;
        //             if(gameData.colorfulPiece[6][0] == 1){
        //                 children[0].children[0].active = true;
        //             }else{
        //                 children[0].children[0].active = false;
        //             }
        //         }
        //     }
        // }

        for (let i = 0; i < this.item.length; i++) {
            if (this.Direction == 0) {
                this.item[i].x -= this._moveSpeed * dt * this.speed;
            } else {
                this.item[i].y -= this._moveSpeed * dt * this.speed;
            }
        }
        if (this._moveSpeed > 0) {
            this._moveSpeed -= dt * this.rub;
            if (this._moveSpeed < 0) {
                this._moveSpeed = 0;
            }
        } else {
            this._moveSpeed += dt * this.rub;
            if (this._moveSpeed > 0) {
                this._moveSpeed = 0;
            }
        }
        let moveTo = -this._moveSpeed * dt * this.speed;
        this.itemMoveBy(cc.v2(moveTo, moveTo));
        this.updatePos();
    }   
}
}